package cate.game.pvp.pointrace.handler;

import cate.game.pvp.pointrace.data.PointRaceRankRwd;
import cate.game.pvp.pointrace.data.PointRaceRankRwd.RwdType;
import lombok.Data;

import java.util.List;

public interface PointRaceRankRwdOperation {

    void upsert(List<PointRaceRankRwd> rankRwdList);

    @Data
    class QueryParam {
        private int season;
        private int srvId;
        private int day;
        private RwdType rwdType;

        public static QueryParam ofDay(int season, int srvId, int day) {
            return of(season, srvId, day, RwdType.DAY);
        }

        public static QueryParam ofSeason(int season, int srvId, int day) {
            return of(season, srvId, day, RwdType.SEASON);
        }

        public static QueryParam of(int season, int srvId, int day, RwdType rwdType) {
            QueryParam param = new QueryParam();
            param.setSeason(season);
            param.setSrvId(srvId);
            param.setDay(day);
            param.setRwdType(rwdType);
            return param;
        }

        public String getIndexedKey() {
            return String.format("%d-%d-%d-%d", season, srvId, day, rwdType.ordinal());
        }
    }

    List<PointRaceRankRwd> query(QueryParam param);
}
